package database;

import java.sql.*;

public class RedisElevel {
    public RedisElevel(){}
    public static int getElevel(String empId){
        // 数据库连接字符串，可能需要根据您的数据库配置进行修改
        String url = "jdbc:mysql://localhost:3306/test?useSSL=false&serverTimezone=UTC";
        String user = "root";
        String password = "123456";

        int empLevel = 0;
        try (Connection conn = DriverManager.getConnection(url, user, password);
             // 调用存储过程
             CallableStatement cstmt = conn.prepareCall("{call GetEmployeeLevel(?, ?)}")) {

            // 注册OUT参数
            cstmt.registerOutParameter(2, Types.INTEGER);

            // 设置输入参数
            cstmt.setString(1, empId);

            // 执行存储过程
            cstmt.execute();

            // 获取输出参数的值
            empLevel = cstmt.getInt(2);


        } catch (SQLException e) {
            e.printStackTrace();
        }
        return empLevel;
    }
}

